package com.example.springboot159.bean.taskConfig;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author matao
 * @date 2021年12月16日 18:39
 */
public class TaskConfigConstant {


    public enum CHANNEL_ID {
        wechat(1, "wechat","wechat"),
        wechat_mini(2, "微信小程序","wechat_mini"),
        alipay(3, "支付宝渠道","alipay"),
        app(4, "app渠道","app");

        private Integer code;
        private String name;
        private String desc;


        CHANNEL_ID(Integer code, String name,String desc) {
            this.code = code;
            this.name = name;
            this.desc = desc;
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }

        public static String getNameByCode(Integer code) {
            CHANNEL_ID[] values = CHANNEL_ID.values();
            Optional<CHANNEL_ID> first = Arrays.stream(values)
                    .filter(e -> e.getCode().equals(code)).findFirst();
            return !first.isPresent() ? "" : first.get().getName();
        }

        public static String getDescByCode(Integer code) {
            CHANNEL_ID[] values = CHANNEL_ID.values();
            Optional<CHANNEL_ID> first = Arrays.stream(values)
                    .filter(e -> e.getCode().equals(code)).findFirst();
            return !first.isPresent() ? "" : first.get().getDesc();
        }
    }

    public enum TaskType{
        dailyTask(1,"每日任务"),
        weekTask(2,"每周任务"),
        monthTask(3,"每月任务"),
        growTask(4,"成长任务");
        private Integer code;
        private String name;

        TaskType(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    //0 下线 1 待上线 2上线
    public enum TASK_STATE {
        OFFLINE(0, "下线"),
        WAIT(1, "待上线"),
        ONLINE(2, "已上线");

        private Integer code;
        private String name;

        TASK_STATE(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

    }

    public enum COMMON_STATE {
        DEL(0, "删除"),
        OK(1, "正常"),
        DRAFT(2, "草稿");

        private Integer code;
        private String name;

        COMMON_STATE(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public static String getNameByCode(Integer code) {
            COMMON_STATE[] values = COMMON_STATE.values();
            Optional<COMMON_STATE> first = Arrays.stream(values)
                    .filter(e -> e.getCode().equals(code)).findFirst();
            return !first.isPresent() ? "" : first.get().getName();
        }
    }

}
